<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <link media="all" rel="stylesheet" th:href="@{/back/lib/layui-v2.6.3/css/layui.css}">
    <link media="all" rel="stylesheet" th:href="@{/back/css/public.css}">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <!--    修改使用的用户ID-->
    <input hidden="hidden" name="id" th:value="${articleComment.id}">
    <div class="layui-form-item">
        <label class="layui-form-label required">文章ID</label>
        <div class="layui-input-block">
            <input class="layui-input" name="articleId" placeholder="请输入文章ID"
                   th:value="${articleComment.articleId}" type="text"
                   lay-verify="required" disabled="disabled" style="background:#CCCCCC">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">作者ID</label>
        <div class="layui-input-block">
            <input class="layui-input" name="userId" placeholder="请输入作者ID" th:value="${articleComment.userId}"
                   type="text"
                   lay-verify="required" disabled="disabled" style="background:#CCCCCC">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">父评论PID</label>
        <div class="layui-input-block">
            <input class="layui-input" name="pid" placeholder="请输入文章作者ID" th:value="${articleComment.pid}"
                   type="text" lay-verify="required" disabled="disabled" style="background:#CCCCCC">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评论的内容</label>
        <div class="layui-input-block">
            <input class="layui-input" name="plContent" placeholder="请输入电子邮箱"
                   th:value="${articleComment.plContent}" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评论状态</label>
        <div class="layui-input-block">
            <input class="layui-input" name="status" placeholder="" th:value="${articleComment.status}" type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">评论用户登录的ip地址</label>
        <div class="layui-input-block">
            <input class="layui-input" name="ip" placeholder="请输入文章缩略图" th:value="${articleComment.ip}"
                   type="text">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-filter="saveBtn" lay-submit>确认保存</button>
        </div>
    </div>
</div>
<script charset="utf-8" th:src="@{/back/lib/layui-v2.6.3/layui.js}"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$;

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {
                $.ajax("/back-article-comment/update", {
                    data: data.field,
                    type: "POST",
                    dataType: "JSON",
                    success: function (result) {
                        console.log(data)
                        if (result.code == 0) {
                            // 关闭弹出层
                            layer.close(index);
                            var iframeIndex = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(iframeIndex);
                            window.parent.location.reload();//父窗口刷新
                        }
                    },
                })
            });
            return false;
        });
    });
</script>
</body>
</html>